/**
 *  背景图
 */
import 'package:flutter_benchu/utils/commonPkg.dart';

class BgImage extends StatelessWidget {
  BgImage({this.loaded,this.splashPng,this.splashGif});

  final bool loaded;            //动画是否结束
  final String splashPng;       //静态图
  final String splashGif;       //动画图
  
  @override
  Widget build(BuildContext context) {

    // 图片
    var stack = new Stack(
      // alignment: const FractionalOffset(0.5, 0.8), //X轴  和Y轴对齐方式
      children: <Widget>[
        Image.asset(
          splashPng,
          height: double.infinity,
          filterQuality: FilterQuality.high,
          fit: BoxFit.fitHeight,
        ),
        if (!loaded)
          Image.asset(
            splashGif,
            height: double.infinity,
            filterQuality: FilterQuality.high,
            fit: BoxFit.fitHeight,
          ),
      ],
    );

    return Container(
      width: MediaQuery.of(context).size.width,
      height: MediaQuery.of(context).size.height,
      decoration: BoxDecoration(
        gradient: LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            colors: [
              Color(0xFF000000),
              Color(0xFF000000),
            ]),
      ),
      child: Center(
        child: stack,
      ),
    );
  }
}
